Use case: ICACHE maintenance operations in interrupt mode

This use case shows how to run an ICACHE invalidate operation in interrupt mode, comparing HAL1 and HAL2.

Sequence diagram

    @startuml
    participant "User\nApplication" order 1
    participant "ICACHE\nDriver" order 2
    participant "ICACHE_IRQHandler" order 3
    "User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_Enable
    "ICACHE\nDriver"-->"User\nApplication":HAL_OK
    note left: return\nstatus
    "User\nApplication"->"ICACHE\nDriver": HAL_ICACHE_Invalidate_IT
    note right: Invalid ICACHE interruption enabled\nthen ICACHE disabled
    "ICACHE\nDriver"-->"User\nApplication":HAL_OK or HAL_ERROR
    note left: return\nstatus
    == Interruption Service Routine ==
    "ICACHE_IRQHandler" <-]:Invalidate\ninterrupt
    "ICACHE_IRQHandler" -> "ICACHE\nDriver" : HAL_ICACHE_IRQHandler
    note left: Interruption execution
    "ICACHE\nDriver"->"User\nApplication":HAL_ICACHE_InvalidateCompleteCallback
    @enduml

Code snippet

HAL1

HAL2

/* Enable ICACHE */
HAL_ICACHE_Enable();

/* Start invalidate in interrupt mode */
if (HAL_ICACHE_Invalidate_IT() != HAL_OK)
{
  Error_Handler();
}

/* In ICACHE_IRQHandler(): */
/* HAL_ICACHE_IRQHandler(); */

/* Completion notification */
/* void HAL_ICACHE_InvalidateCompleteCallback(void) { ... } */
/* Optional: register callback */
(void)HAL_ICACHE_RegisterInvalidateCompleteCallback(&hicache1, myICACHE_InvalidateCompleteCallback);

/* Start ICACHE */
if (HAL_ICACHE_Start(&hicache1, HAL_ICACHE_IT_NONE) != HAL_OK)
{
  Error_Handler();
}

/* Start invalidate in interrupt mode */
if (HAL_ICACHE_Invalidate_IT(&hicache1) != HAL_OK)
{
  Error_Handler();
}

/* In ICACHE_IRQHandler(): */
/* HAL_ICACHE_IRQHandler(&hicache1); */

Key changes

  1. HAL2 uses handle-based APIs and a start step (HAL_ICACHE_Start()), while HAL1 uses HAL_ICACHE_Enable().

  2. HAL2 supports callback registration (when USE_HAL_ICACHE_REGISTER_CALLBACKS is enabled) for invalidate-complete notification.

  3. HAL2 keeps the same high-level interrupt flow (request invalidate, then handle in IRQ), but with updated signatures and naming.